{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='../../plugin/lingze/template/web/common_nav'}
    {if $method == "flag_main"}
    <div class="panel panel-info">
        <div class="panel-heading">当前数量： {$page_total}</div>
        <div class="panel-body">
            <form id = "myform" action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{$_P['m']}" />
                <input type="hidden" name="do" value="web" />
                <input type="hidden" name="r" value="lingze.flag.search" />
                <input type="hidden" name="themeid" value="{$themeid}" />
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">手机号、微信昵称</label>
                    <div class="col-sm-9 col-xs-9 col-md-9">
                        <input class="form-control" name="search_data" placeholder="输入报名手机号或微信昵称或兑换码" type="text" value="{$_P['search_data']}">
                    </div>
                </div>
                <div class="form-group clearfix">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">浏览时间</label>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        {php echo view_form_field_daterange('createtime', array('start' => $start_day, 'end' => $end_day));}
                    </div>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                        <input type="hidden" name="__token__" value="{$Request.token}"/>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-5 col-lg-5 col-md-5 col-xs-5">
                        {if $page_total<=5000}
                        <input class="btn btn-default" type="submit" name="export_submit" onclick="jump()" id="export_submit" value="导出EXCEL">
                        {else}
                        <input class="btn btn-default" type="submit" name="export_submit" onclick="jump()" id="export_submit" value="导出EXCEL(1-5000条)">
                        {/if}
                        {if $page_total>5000}
                        <input class="btn btn-default" type="submit" name="export_submit2" onclick="jump()" id="export_submit2" value="导出(5001-10000)">
                        {/if}
                        {if $page_total>10000}
                        <input class="btn btn-default" type="submit" name="export_submit3" onclick="jump()" id="export_submit3" value="导出(10001-15000)">
                        {/if}
                        {if $page_total>15000}
                        <input class="btn btn-default" type="submit" name="export_submit4" onclick="jump()" id="export_submit4" value="导出(15001-20000)">
                        {/if}
                        {if $page_total>20000}
                        <input class="btn btn-default" type="submit" name="export_submit5" onclick="jump()" id="export_submit5" value="导出(20001-25000)">
                        {/if}
                        {if $page_total>25000}
                        <input class="btn btn-default" type="submit" name="export_submit5" onclick="jump()" id="export_submit5" value="导出(25001-30000)">
                        {/if}
                    </div>
                </div>
            </form>
        </div>
    </div>
    {/if}

    <div class="tab-content">
        <div class="panel panel-default">
            <div class="panel-body table-responsive">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width: 50px">序号</th>
                        <th style="width: 120px">用户昵称</th>
                        <th style="width: 120px">用户报名信息</th>
                        <th style="width: 100px">用户头像</th>
                        <th style="width: 100px">奖品名称</th>
                        <th style="width: 100px">宝箱名称</th>
                        <th style="width: 100px">奖品图片</th>
                        <th style="width: 100px">通关关卡</th>
                        <th style="width: 100px">状态</th>
                        <th style="width: 100px">更新时间</th>
                        <th style="width: 100px">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {loop $list $index $item}
                    <tr>
                        <td>{$item['f_id']}</td>
                        <td>{$item['nickname']}</td>
                        <td>{$item['username']}<br/>{$item['mobile']}</td>
                        <td>
                            <img src="{php echo tomedia($item['avatar']);}" style="width: 40px;height: 40px;padding: 1px;">
                        </td>
                        <td>{$item['chest_name']}</td>
                        <td>{$item['box_name']}</td>
                        <td>
                            <img src="{php echo tomedia($item['small_img']);}" style="width: 40px;height: 40px;padding: 1px;">
                        </td>
                        <td>通过第{$item['level_sort']}关</td>
                        <td>
                            {if $item['status']==1}
                            <span class="label label-warning">待兑换</span>
                            {elseif $item['status']==2}
                            <span class="label label-success">已兑换其他，当前失效</span>
                            {elseif $item['status']==3}
                            <span class="label label-danger">已兑换</span>
                            {elseif $item['status']==4}
                            <span class="label label-success">已核销</span>
                            {else}
                            {/if}
                        </td>
                        <td>
                            {$item['created_at']}
                        </td>
                        <td>
                            {if $item['status']==3}
                            <a class="btn btn-danger btn-sm" style="width: 35px" onclick="changeOrDelItem(this)" data-type="convert"
                               data-edit-url="" data-themeid="{$themeid}" data-id="{$item['f_id']}" title="核销奖品" data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i></a>
                            {/if}
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

{$pager}
<script type="text/javascript">
    $(document).ready(

    );
    function jump(){
        layer.msg('正在准备下载');
    }
    // 修改、删除
    function changeOrDelItem(e) {
        let f_id = e.getAttribute("data-id");
        let type = e.getAttribute("data-type");
        let themeid = e.getAttribute("data-themeid");
        let postUrl ="";
        if (type=='convert'){
            postUrl = "{php echo createWebUrlPlugin('lottery');}";
            layer.msg('您确定核销该奖品吗？核销后本用户其他奖品失效',{
                btn:['确定','取消'],
                yes:function (index) {
                    $.ajax({
                        url:postUrl,
                        dataType:'json',
                        method:'post',
                        data: {f_id:f_id,themeid:themeid},
                        success:function (e) {
                            let res = e.message;
                            let code = res.code;
                            let msg = res.msg;
                            if (code!=200){
                                layer.msg(msg);
                            }else{
                                layer.msg(msg);
                                location.reload();
                            }
                        },
                        fail:function (err) {
                            console.log(err)
                        }
                    });
                }
            });
        }
    }
</script>
